package com.unidt.www.module.expert.controller.admin;

import com.unidt.www.framework.common.pojo.CommonResult;
import com.unidt.www.module.expert.form.*;
import com.unidt.www.module.expert.service.InvitationDataService;
import com.unidt.www.module.expert.vo.ExpertInfoUserDataVo;
import com.unidt.www.module.expert.vo.ExpertListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * @Author sk
 * @Description:
 * @Date 2022/12/15 16:09
 **/
@Api(tags = "管理后台-专家邀约")
@RestController
@RequestMapping("/expert/invitation")
public class InvitationOptController {

    @Autowired
    InvitationDataService invitationRuleService;

    /**
     * 功能描述: 加载
     * @author sk
     * @date 2022/12/15
     * @param loadForm
     * @return com.unidt.www.framework.common.pojo.CommonResult
     */
    @PostMapping("/loadData")
    @ApiOperation(value = "动态规则数据筛查")
    public CommonResult<ExpertInfoUserDataVo> load(@Validated @RequestBody InvitationRuleLoadForm loadForm){

        return  CommonResult.success(this.invitationRuleService.load(loadForm)) ;
    }

    /**
     * 功能描述: 定向数据加载
     * @author sk
     * @date 2023/1/3
     * @param loadForm
     * @return com.unidt.www.framework.common.pojo.CommonResult<com.unidt.www.module.expert.vo.ExpertInfoUserDataVo>
     */
    @PostMapping("/directionalLoad")
    @ApiOperation(value = "定向数据筛查")
    public CommonResult<ExpertInfoUserDataVo> directionalLoad(@RequestBody DirectionalRuleForm loadForm){

        return  CommonResult.success(this.invitationRuleService.directionalLoad(loadForm)) ;
    }


    /**
     * 功能描述: 删除邀约专家
     * @author sk
     * @date 2023/1/3
     * @param loadKey
     * @param expertId
     * @return com.unidt.www.framework.common.pojo.CommonResult
     */

    @DeleteMapping("/deleteExpert/{loadKey}/{expertId}")
    @ApiOperation(value = "删除邀约专家")
    public CommonResult deleteExpert(@PathVariable(value = "loadKey") String loadKey,@PathVariable(value = "expertId")Long expertId){

        return  CommonResult.success(this.invitationRuleService.deleteExpert(loadKey,expertId)) ;
    }



    /**
     * 功能描述: 定向邀约专家名单保存
     * @author sk
     * @date 2023/1/3
     * @param directionalRuleForm
     * @return com.unidt.www.framework.common.pojo.CommonResult
     */
    @PostMapping("/saveExperts")
    @ApiOperation(value = "保存定向邀约专家名单")
    public CommonResult saveExperts(@RequestBody ExpertInfoUserDataForm directionalRuleForm){

        return  CommonResult.from(this.invitationRuleService.saveExperts(directionalRuleForm)) ;
    }


    /**
     * 功能描述: 获取邀约数据
     * @author sk
     * @date 2023/1/3
     * @param key
     * @return com.unidt.www.framework.common.pojo.CommonResult<com.unidt.www.module.expert.vo.ExpertListVo>
     */
    @GetMapping("/loadByKey/{key}")
    @ApiOperation(value = "获取筛选数据")
    public CommonResult<ExpertListVo> loadByKey(@PathVariable("key") String key){

        return  CommonResult.success(this.invitationRuleService.loadByKey(key)) ;
    }


    /**
     * 功能描述: 保存邀约
     * @author sk
     * @date 2023/1/3
     * @param invitationForm
     * @return com.unidt.www.framework.common.pojo.CommonResult
     */
    @PostMapping("/save")
    @ApiOperation(value = "保存")
    public CommonResult save(@RequestBody ExpertInvitationForm invitationForm){


        return  CommonResult.from(this.invitationRuleService.save(invitationForm));
    }

    /**
     * 功能描述: 专家取消（替换）
     * @author sk
     * @date 2023/1/3
     * @param expertCancelForm
     * @return com.unidt.www.framework.common.pojo.CommonResult
     */
    @PostMapping("/cancel")
    @ApiOperation(value = "专家取消")
    public CommonResult cancel(@RequestBody ExpertCancelForm expertCancelForm){

        return  CommonResult.from(this.invitationRuleService.cancel(expertCancelForm));
    }


    /**
     * 功能描述: 邀约删除
     * @author sk
     * @date 2023/1/3
     * @param id
     * @return com.unidt.www.framework.common.pojo.CommonResult
     */

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除邀约")
    public CommonResult delete(@PathVariable(value = "id") Long id){

        return  CommonResult.from(this.invitationRuleService.delete(id));
    }

    /**
     * 功能描述: 名单确认
     * @author sk
     * @date 2023/1/3
     * @param id
     * @return com.unidt.www.framework.common.pojo.CommonResult
     */
    @PostMapping("/confirm/{id}")
    @ApiOperation(value = "名单确认")
    public CommonResult confirm(@PathVariable(value = "id")Long id){

        return  CommonResult.from(this.invitationRuleService.confirm(id));

    }

    /**
     * 功能描述: 开启
     * @author sk
     * @date 2023/1/3
     * @param id
     * @return com.unidt.www.framework.common.pojo.CommonResult
     */
    @PostMapping("/start/{id}")
    @ApiOperation(value = "开启")
    public CommonResult start(@PathVariable(value = "id")Long id){

        return  CommonResult.from(this.invitationRuleService.start(id));

    }

}
